package com.lly.tboc

import io.kotest.assertions.asClue
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.ints.shouldNotBeLessThan
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import java.io.File


class ZhouYiTest2 : StringSpec({

    "解析周易文本数据" {
        val data =
            com.lly.tboc.zhouyi.parseData(
                File("src/main/assets/zhouyi_jichang.txt")
            )
        data.forEachIndexed { i, gua ->
            /* println(gua)
             gua.data.forEach {
                 println("\t$it")
             }*/
            gua.asClue {
                gua.id shouldBe i + 1
                gua.name shouldNotBe ""
                gua.ci shouldNotBe ""
                gua.tuan shouldNotBe ""
                gua.xiang shouldNotBe ""
                gua.outer shouldNotBe ""
                gua.inner shouldNotBe ""

                gua.data.forEachIndexed { index, yao ->
                    yao.asClue {
                        yao.id shouldBe index + 1
                        yao.name shouldNotBe ""
                        yao.ci shouldNotBe ""
                        yao.xiang shouldNotBe ""
                    }
                }
                gua.data.asClue {
                    it.size shouldNotBeLessThan 6

                }
                if (gua.id == 1 || gua.id == 2) {
                    gua.wenyan shouldNotBe ""
                    println(gua.wenyan)
                }else{
                    gua.wenyan shouldBe ""
                }
            }

        }
        data.size shouldBe 64
    }
    "中文数字转阿拉伯数字" {
        com.lly.tboc.zhouyi.chinese2Num("一") shouldBe 1
        com.lly.tboc.zhouyi.chinese2Num("十") shouldBe 10
        com.lly.tboc.zhouyi.chinese2Num("二十三") shouldBe 23
        com.lly.tboc.zhouyi.chinese2Num("六十四") shouldBe 64
    }

})


